import request from '@/utils/request'

// 用户列表
export function listUser(data) {
  return request({
    url: `/business_admin/user/list`,
    method: 'post',
    data: data
  })
}

// export function fetchMenus(data) {
//   return request({
//     url: `/business_admin/user/all_menus`,
//     method: 'get',
//     data: data
//   })
// }

// 创建用户
export function addUser(data) {
  return request({
    url: `/business_admin/user/create`,
    method: 'post',
    data: data
  })
}

// 创建用户二维码
export function addUserQrCode(params) {
  return request({
    url: '/business_admin/user/apply_qrCode',
    method: 'post',
    params: params
  })
}

// 获取用户审批列表
export function getUserApproveList(params) {
  return request({
    url: '/business_admin/user/apply_list',
    method: 'get',
    params: params
  })
}

// 获取用户审批列表
export function approveUser(data) {
  return request({
    url: '/business_admin/user/approve_apply',
    method: 'post',
    data: data
  })
}

export function getUser(userId) {
  const params = { userId }
  return request({
    url: `/business_admin/user/detail`,
    method: 'get',
    params: params
  })
}

// 更新用户信息
export function updateUser(userId, data) {
  data.id = userId
  return request({
    url: `/business_admin/user/update`,
    method: 'post',
    data: data
  })
}

// 删除用户
export function deleteUser(userId) {
  return request({
    url: `/business_admin/user/delete`,
    method: 'post',
    data: {
      userId
    }
  })
}
// 是否可删除
export function isCanDelete(userId) {
  return request({
    url: `business_admin/role/isCanDelete?roleId=${userId}`,
    method: 'get',
    data: {
      userId
    }
  })
}

// 修改用户密码
export function resetKdUserPw(data) {
  return request({
    url: `/business_admin/user/reset_pw`,
    method: 'post',
    data: data
  })
}

// 获取用户推广二维码
export function getUserQrCode(params) {
  return request({
    url: '/memberAdmin/inviteMember/empInviteQrCode',
    method: 'get',
    params: params
  })
}
